import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

class ToastUtil {
  // 统一配置默认样式
  static const _defaultBgColor = Colors.black54;
  static const _defaultTextColor = Colors.white;
  static const _defaultFontSize = 16.0;
  static const _defaultGravity = ToastGravity.BOTTOM;

  // 显示 Toast（只传必要参数）
  static void show(
    String msg, {
    Toast toastLength = Toast.LENGTH_SHORT,
    Color? backgroundColor,
    Color? textColor,
    double? fontSize,
    ToastGravity? gravity = ToastGravity.CENTER,
  }) {
    Fluttertoast.showToast(
      msg: msg,
      toastLength: toastLength,
      gravity: gravity ?? _defaultGravity,
      backgroundColor: backgroundColor ?? _defaultBgColor,
      textColor: textColor ?? _defaultTextColor,
      fontSize: fontSize ?? _defaultFontSize,
    );
  }
}
